Passed
Push — master ( d2bce4...71830f )
by Dmytro
130:29 queued 126:43
created

API.initLogger   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
1
import sinon from 'sinon';
2
import { getNamespace } from 'cls-hooked';
3
import { apiLogger } from '../logger';
4
import { load } from '../utils';
5
6
const ATLASSIAN_API = load('AtlassianApi').default;
7
8
class API extends ATLASSIAN_API {
9
    async getMyself() {
10
        return {
11
            id    : 1,
12
            email : this.auth.username,
13
            name  : 'Tyler Simpson'
14
        };
15
    }
16
17
    getTraceId() {
18
        return getNamespace('__TEST__').get('current').id;
19
    }
20
21
    initLogger() {
22
        this.logger = apiLogger;
23
    }
24
}
25
26
const methods = Object.getOwnPropertyNames(API.prototype).filter(m => m !== 'constructor');
27
28
methods.forEach(methodName => {
29
    sinon.replace(ATLASSIAN_API.prototype, methodName, API.prototype[methodName]);
30
});
31